package com.yunxun.coinmessage.dao;

import com.yunxun.coinmessage.entity.Exchange;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface ExchangeDao {
    @Insert("insert into exchange(ename,eurl,eintro)values(#{ename},#{eurl},#{eintro})")
    Integer addExchange(Exchange exchange);
    @Select("select * from exchange where status=1 ")
    List<Exchange> queryAll();
    @Select("select * from exchange where status=1 limit #{start},#{limit} ")
    List<Exchange> queryByPage(@Param("start")int start,@Param("limit")int limit);
    @Select("select * from exchange where eid=#{eid}")
    Exchange queryById(Integer eid);
    @Update("update exchange set status=0 where eid=#{eid}")
    Integer deleteById(Integer eid);
    //根据交易所id更新交易所
    @Update("update exchange set ename=#{ename},eurl=#{eurl},eintro=#{eintro} where eid=#{eid}")
    Integer updateById(Exchange exchange);
    //查询交易所的数量
    @Select("select count(*) from exchange where status=1")
    Integer queryTotal();
    //按交易所名字查询
    @Select("select * from exchange where ename=#{ename}")
    List<Exchange> queryByName(String ename);

}
